import Cookies from 'js-cookie';

const user = {
    state: {
        user: {}
    },
    mutations: {
    	// 登录
    	login(state, user) {
    		state.user = user;
    		Cookies.set('user_id', user.id);
    		Cookies.set('token', user.token);
    	},
    	// 登出
    	logout(state) {
    		state.user = {};
    		Cookies.remove('user_id');
    		Cookies.remove('token');
    	},
        // 登录用户信息
        updateUserInfo (state, user) {
            state.user = user;
        },
    }
};

export default user;
